<?php
define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');
include_once('../fm/comm.php');
$myt = new thunder();

/* 检查权限 */
admin_priv('users_manage');

if(isset($_REQUEST['act']) && $_REQUEST['act']=='add'){
	$c_id = $_POST['c_id'];

	$sql = "insert into `kd_custom_goods_config` (cid,memo)values($c_id,'')";
	//var_dump($sql);
	$re = $myt->query($sql);
	if($re){
		echo "<script>alert('保存完成');</script>";
	}
}
if(isset($_REQUEST['act']) && $_REQUEST['act']=='del'){
	$id = $_REQUEST['id'];

	$sql = "delete from `kd_custom_goods_config` where id=$id";
	//var_dump($sql);
	$re = $myt->exe($sql);
	if($re){
		echo "<script>alert('删除完成');</script>";
	}
}

$sql = "select a.*,b.goods_name from kd_custom_goods_config as a left join ecs_goods as b on a.cid=b.goods_id ";
$data = $myt->getAll($sql);
//var_dump($data);

$smarty->assign('cgdata', $data);
$smarty->assign('category', cat_list(0, 0, true));
$smarty->assign('kd_goods', '');



/* 显示页面 */
assign_query_info();
$smarty->display('kd_custom_goods_config.htm');
?>